import type { FormRules } from "naive-ui";
import { requiredRule } from "@/utils";
import { CATALOG_CODE, PAGE_CODE, BUTTON_CODE } from "../config";
import Catalog from "~icons/uil/folder";
import Page from "~icons/ph/stack-bold";
import Button from "~icons/mdi/radiobox-marked";

export const rules: FormRules = {
  type: {
    type: "number",
    ...requiredRule("请选择菜单类型"),
  },
  title: requiredRule("请输入菜单名称"),
  name: requiredRule("请输入路由名称"),
  path: requiredRule("请输入路由路径"),
  component: requiredRule("请选择菜单组件"),
  newTab: {
    type: "boolean",
    ...requiredRule("请选择打开方式"),
  },
};

export interface MenuType {
  label: string;
  value: number;
  icon: Component;
}
export const menuTypes = {
  catalog: {
    label: "目录",
    value: CATALOG_CODE,
    icon: <Catalog />,
  } as MenuType,
  page: { label: "页面", value: PAGE_CODE, icon: <Page /> } as MenuType,
  button: { label: "按钮", value: BUTTON_CODE, icon: <Button /> } as MenuType,
};
